<?php

function q(&$item, $key, $char)/*{{{*/
{
	$item = $char.$item.$char;
}/*}}}*/
function DB_connect($db_address, $db_user, $db_pass, $db_name)
{
	$conn = mysql_connect($db_address, $db_user, $db_pass)or die(mysql_error());
	mysql_select_db($db_name, $conn);

	return $conn;
}

function DB_close()
{
	return mysql_close();
}

/* string $sql */
function query($sql)
{	
	($result = mysql_query($sql)) || die(mysql_error());
	return $result;
}

/* resource $result */
function get_row($result, $result_type = MYSQL_BOTH)
{
	return mysql_fetch_array($result, $result_type);
}

function get_rows($result, $result_type = MYSQL_BOTH)
{
	$return = array();
	while($data = get_row($result, $result_type))
		$return[] = $data;

	return $return;
}



/* db info */
$db_user = "mage";	//database account 
$db_pass = "mage";	//database password
$db_address = "localhost";
$db_name = "mage";	//database name


DB_connect($db_address, $db_user, $db_pass, $db_name);
?>
